using Godot;
public class BreaKing
{
    public Vector3I location;
    private bool isBreaking = false;
    float Max;
    float Pace;
    float Speed;
    public BreaKing()
    {

    }
    public void Set(Vector3I l, float Max, float Speed)
    {
        this.Max = Max;
        this.Speed = Speed;
        this.Pace = 0;
        location = l;
        isBreaking = true;
    }
    public bool Updata(Vector3I target, float delta)
    {
        if (location.X != target.X || location.Y != target.Y)
        {
            location = target;
            Pace = 0;
            isBreaking = false;
            return false;
        }

        if (isBreaking)
        {
            if (Pace >= Max)
            {
                Pace = 0;
                isBreaking = false;
                return true;
            }
            else
            {
                Pace += Speed * delta;
                return false;
            }
        }
        else
        {
            return false;
        }
    }
    public void Reset()
    {
        isBreaking = false;
        Pace = 0;
        Speed = 0;
    }
    public bool GetBreaking()
    {
        return isBreaking;
    }
    public int getPace()
    {
        if (isBreaking)
        {
            int i = (int)(1 + (Pace / Max) * 8);
            if (i > 8) i = 8;
            if (i < 0) i = 0;
            return i;
        }
        else
        {
            return 0;
        }
    }
}